/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.faces.model.SelectItem;
import queenb.net.entitybean.C250;
import queenb.net.entitybean.N420;
import queenb.net.entitybean.N850;
import queenb.web.crm.store.N850Store;
import queenb.web.organization.store.C250Store;
import queenb.web.store.N420Store;
import queenb.web.util.ContextUtil;
import queenb.web.util.Util;

/**
 *
 * @author Ka
 */
public class N420Controller extends QueenbController{

    private int pn420;
    private int fn100;
    private int fn850; // nhom to
    private int fc250; //ca lam viec
    private Date nd421;
    private String nv422;
    private String nv423;
    private String nv424;
    private String nv425;
    private String nv426;
    private String nv427;
    private String nv428;
    private Date nd429;
    private String nv430;
    private int fn370;
    private int fn400;
    private Date nl445;
    private Date nl446;
    private String nl447;
    private Date nl448;
    private String nl449;
    
    private String nv116; // mã nhân viên
    private String nv107; // số  đt
    private String nv109; // cmnd
    private String nv852; // nhom tổ
    private String nv110; // passport
    private String nv451; // bộ phận
    
   
    //tham so truyen vao 
    int fh000; 
    int fh200; 
    private Date nd401; 
    //

    
    private List<N420> listN420;
    private N420Store n420Store;
    private N850Store n850Store;
    private C250Store c250Store;
    
    public N420Controller() throws ParseException
    {
        getKapiMenu().setAdmin(false);
        getKapiMenu().setMainmenu1("m201");
        
        n420Store = new N420Store();
        n850Store = new N850Store();
        c250Store = new C250Store();
        Object objAction = getRequest().getParameter("action");
        if(objAction != null){
            if(objAction.equals("listN420")){
                Object objFN850 = getRequest().getParameter("fn850");
                if(objFN850 != null){
                    this.fn850 =Integer.parseInt(objFN850.toString());
                    
                }
                Object objfc250 = getRequest().getParameter("fc250");
                if(objfc250 != null){
                    this.fc250 = Integer.parseInt(objfc250.toString());
                }
                Object objStarDate = getRequest().getParameter("stardate");
                if(!objStarDate.toString().equals("null")){
                    setNd401(Util.parseDate(objStarDate.toString(), "dd/MM/yyyy"));
                }
                else
                    setNd401(null);
                System.out.println("---list 430---"+getLogin().getModule()+","+getLogin().getCompanyNo()+","+nd401+","+ this.getFc250()+","+ this.getFn850()+","+ getLogin().getUserName());
                listN420 =  n420Store.getListN420(getLogin().getModule(), getLogin().getCompanyNo(),Util.toSQLDate(nd401), this.getFc250(), this.getFn850(), getLogin().getUserName());
            }
        }
    }
    
    /**
     * @return the pn420
     */
    public int getPn420() {
        return pn420;
    }

    /**
     * @param pn420 the pn420 to set
     */
    public void setPn420(int pn420) {
        this.pn420 = pn420;
    }

    /**
     * @return the fn100
     */
    public int getFn100() {
        return fn100;
    }

    /**
     * @param fn100 the fn100 to set
     */
    public void setFn100(int fn100) {
        this.fn100 = fn100;
    }

    /**
     * @return the fn850
     */
    public int getFn850() {
        return fn850;
    }

    /**
     * @param fn850 the fn850 to set
     */
    public void setFn850(int fn850) {
        this.fn850 = fn850;
    }

    /**
     * @return the fc250
     */
    public int getFc250() {
        return fc250;
    }

    /**
     * @param fc250 the fc250 to set
     */
    public void setFc250(int fc250) {
        this.fc250 = fc250;
    }

    /**
     * @return the nd421
     */
    public Date getNd421() {
        return nd421;
    }

    /**
     * @param nd421 the nd421 to set
     */
    public void setNd421(Date nd421) {
        this.nd421 = nd421;
    }

    /**
     * @return the nv422
     */
    public String getNv422() {
        return nv422;
    }

    /**
     * @param nv422 the nv422 to set
     */
    public void setNv422(String nv422) {
        this.nv422 = nv422;
    }

    /**
     * @return the nv423
     */
    public String getNv423() {
        return nv423;
    }

    /**
     * @param nv423 the nv423 to set
     */
    public void setNv423(String nv423) {
        this.nv423 = nv423;
    }

    /**
     * @return the nv424
     */
    public String getNv424() {
        return nv424;
    }

    /**
     * @param nv424 the nv424 to set
     */
    public void setNv424(String nv424) {
        this.nv424 = nv424;
    }

    /**
     * @return the nv425
     */
    public String getNv425() {
        return nv425;
    }

    /**
     * @param nv425 the nv425 to set
     */
    public void setNv425(String nv425) {
        this.nv425 = nv425;
    }

    /**
     * @return the nv426
     */
    public String getNv426() {
        return nv426;
    }

    /**
     * @param nv426 the nv426 to set
     */
    public void setNv426(String nv426) {
        this.nv426 = nv426;
    }

    /**
     * @return the nv427
     */
    public String getNv427() {
        return nv427;
    }

    /**
     * @param nv427 the nv427 to set
     */
    public void setNv427(String nv427) {
        this.nv427 = nv427;
    }

    /**
     * @return the nv428
     */
    public String getNv428() {
        return nv428;
    }

    /**
     * @param nv428 the nv428 to set
     */
    public void setNv428(String nv428) {
        this.nv428 = nv428;
    }

    /**
     * @return the nd429
     */
    public Date getNd429() {
        return nd429;
    }

    /**
     * @param nd429 the nd429 to set
     */
    public void setNd429(Date nd429) {
        this.nd429 = nd429;
    }

    /**
     * @return the nv430
     */
    public String getNv430() {
        return nv430;
    }

    /**
     * @param nv430 the nv430 to set
     */
    public void setNv430(String nv430) {
        this.nv430 = nv430;
    }

    /**
     * @return the fn370
     */
    public int getFn370() {
        return fn370;
    }

    /**
     * @param fn370 the fn370 to set
     */
    public void setFn370(int fn370) {
        this.fn370 = fn370;
    }

    /**
     * @return the fn400
     */
    public int getFn400() {
        return fn400;
    }

    /**
     * @param fn400 the fn400 to set
     */
    public void setFn400(int fn400) {
        this.fn400 = fn400;
    }

    /**
     * @return the nl445
     */
    public Date getNl445() {
        return nl445;
    }

    /**
     * @param nl445 the nl445 to set
     */
    public void setNl445(Date nl445) {
        this.nl445 = nl445;
    }

    /**
     * @return the nl446
     */
    public Date getNl446() {
        return nl446;
    }

    /**
     * @param nl446 the nl446 to set
     */
    public void setNl446(Date nl446) {
        this.nl446 = nl446;
    }

    /**
     * @return the nl447
     */
    public String getNl447() {
        return nl447;
    }

    /**
     * @param nl447 the nl447 to set
     */
    public void setNl447(String nl447) {
        this.nl447 = nl447;
    }

    /**
     * @return the nl448
     */
    public Date getNl448() {
        return nl448;
    }

    /**
     * @param nl448 the nl448 to set
     */
    public void setNl448(Date nl448) {
        this.nl448 = nl448;
    }

    /**
     * @return the nl449
     */
    public String getNl449() {
        return nl449;
    }

    /**
     * @param nl449 the nl449 to set
     */
    public void setNl449(String nl449) {
        this.nl449 = nl449;
    }

    /**
     * @return the listN420
     */
    public List<N420> getListN420(){
//        String date = ContextUtil.getRequestParameter("leavedate1");
//        if (date!=null && !date.equals("")) {
//            setNd401(Util.parseDate(date, "dd/MM/yyyy"));
//        } else {
//            setNd401(null);
//        }
//        
//        int temp1 = getLogin().getModule();
//        int temp2 = getLogin().getCompanyNo();
//        int temp3 = this.getFc250();
//        int temp4 = this.getFn850();
//        String temp5 = getLogin().getUserName();
//        
//        listN420 = n420Store.getListN420(getLogin().getModule(), getLogin().getCompanyNo(), getNd401(), this.getFc250(), this.getFn850(), getLogin().getUserName());
        
        return listN420;
    }

    /**
     * @param listN420 the listN420 to set
     */
    public void setListN420(List<N420> listN420) {
        this.listN420 = listN420;
    }

    /**
     * @return the n850Store
     */
    public N850Store getN850Store() {
        return n850Store;
    }

    /**
     * @param n850Store the n850Store to set
     */
    public void setN850Store(N850Store n850Store) {
       
        this.n850Store = n850Store;
    }

    /**
     * @return the c250Store
     */
    public C250Store getC250Store() {
        return c250Store;
    }

    /**
     * @param c250Store the c250Store to set
     */
    public void setC250Store(C250Store c250Store) {
        this.c250Store = c250Store;
    }
    
    
    public List<SelectItem> getListTabN850()
    {
        List<N850> list=  n850Store.findAllN850(getLogin().getUserName(), getLogin().getModule(),getLogin().getCompanyNo());
        Iterator ic = list.iterator();
        List<SelectItem> listTabN850 = new ArrayList<SelectItem>();
        
        SelectItem item1 = new SelectItem(0, "Tất cả");
        listTabN850.add(item1);
        while (ic.hasNext()) {
            N850 n850 = (N850) ic.next();
            SelectItem item = new SelectItem(n850.getPn850(), n850.getNv851());
            listTabN850.add(item);
        }
        return listTabN850;
    }
    
    public List<SelectItem> getListTabC250()
    {
        List<C250> list = c250Store.COMBTABC250(getLogin().getModule(), getLogin().getCompanyNo(), getLogin().getUserName());
        Iterator ic = list.iterator();
        List<SelectItem> listTabC250 = new ArrayList<SelectItem>();
        SelectItem item1 = new SelectItem(0, "Tất cả");
        listTabC250.add(item1);
        while (ic.hasNext()) {
            C250 c250 = (C250) ic.next();
            SelectItem item = new SelectItem(c250.getVal(), c250.getLabel());
            listTabC250.add(item);
        }
        return listTabC250;
    }

    /**
     * @return the nd401
     */
    public Date getNd401() {
        return nd401;
    }

    /**
     * @param nd401 the nd401 to set
     */
    public void setNd401(Date nd401) {
        this.nd401 = nd401;
    }

    /**
     * @return the nv116
     */
    public String getNv116() {
        return nv116;
    }

    /**
     * @param nv116 the nv116 to set
     */
    public void setNv116(String nv116) {
        this.nv116 = nv116;
    }

    /**
     * @return the nv107
     */
    public String getNv107() {
        return nv107;
    }

    /**
     * @param nv107 the nv107 to set
     */
    public void setNv107(String nv107) {
        this.nv107 = nv107;
    }

    /**
     * @return the nv109
     */
    public String getNv109() {
        return nv109;
    }

    /**
     * @param nv109 the nv109 to set
     */
    public void setNv109(String nv109) {
        this.nv109 = nv109;
    }

    /**
     * @return the nv852
     */
    public String getNv852() {
        return nv852;
    }

    /**
     * @param nv852 the nv852 to set
     */
    public void setNv852(String nv852) {
        this.nv852 = nv852;
    }

    /**
     * @return the nv110
     */
    public String getNv110() {
        return nv110;
    }

    /**
     * @param nv110 the nv110 to set
     */
    public void setNv110(String nv110) {
        this.nv110 = nv110;
    }

    /**
     * @return the nv451
     */
    public String getNv451() {
        return nv451;
    }

    /**
     * @param nv451 the nv451 to set
     */
    public void setNv451(String nv451) {
        this.nv451 = nv451;
    }



}